<?php
if($actPost=="updatephotos")
{
    $categoryId     = gpc_getIntPost("Category");
    $listname		= gpc_getStringArray("ListName");
    $listurl		= gpc_getStringArray("ListUrl");
    $listid			= gpc_getStringArray("ListId");
    $listorder		= gpc_getStringArray("listorder");

    foreach($listid as $i=> $id)
    {
        $id=intval($id);
        if($listurl[$i]==-1 && $id>0)
        {
            //echo $id;exit;
            $sql_delete="delete from tbllocation_photo where iId=$id";
            $dbsql->query($sql_delete);
        }
        elseif($id<=0)
        {
        	$sql_insert = "INSERT INTO tbllocation_photo
        					(iParentId,cName,iStatus,cImage,iOrder,cType,cLanguage)
        				VALUE($categoryId,'$listname[$i]','1','$listurl[$i]',1,'location','$language')";

        	$dbsql->query($sql_insert);
        }
        else
        {
            $sql_update = "UPDATE tbllocation_photo SET
                			 cName = '$listname[$i]',
                             iOrder= '$listorder[$i]'
                			 WHERE iId = '$id'";
            $dbsql->query($sql_update);
        }
    }
    page_transfer("Photos of Destination Saved");
}else
{
    $sql_select = "select cName from tbllocation where iId=$id";
    $location   = $dbsql->query_fetch($sql_select);
    $photos     = ListPhotoLocation($id);  
}
?>